Added Dockerfile and Docker-compose#12
Conversation
There was a problem hiding this comment.
For review purposes it's fine, but we should never push the changes with a .env file. The reason is that, this .env is environment specific. On our PC there might be a MySQL server running locally with a different username and password.
Similarly, Another team member may spin up a container and point to a MySQL server running on cloud.
|
|
||
| # Copy the built JAR file from the Maven build stage | ||
| COPY --from=build /app/target/rihal-0.0.1-SNAPSHOT.jar rihal-0.0.1-SNAPSHOT.jar | ||
| ENTRYPOINT ["sh", "-c","java", "-jar", "rihal-0.0.1-SNAPSHOT.jar"] |
There was a problem hiding this comment.
Is there any benefit of running java through "sh" and not directly using ENTRYPOINT ["java", "-jar", "/app/your-application.jar"] ?
| environment: | ||
| SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3307/usersystem?useSSL=false&serverTimezone=UTC&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true | ||
| SPRING_DATASOURCE_USERNAME: root | ||
| SPRING_DATASOURCE_PASSWORD: root |
There was a problem hiding this comment.
We should never push the password on GitHub.
Using the .env file can help solve this issue.
| EXPOSE 8080 | ||
|
|
||
| #ENV | ||
| ENV SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3307/usersystem?useSSL=false&serverTimezone=UTC&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true |
There was a problem hiding this comment.
Is there a need to hardcode these env variables, when they are also defined in the docker-compose.yaml ?
I have containerized a Spring Boot MVC application alongside a MySQL database using Docker and Docker Compose. The Dockerfile is configured to build the Spring Boot application using Maven and OpenJDK 17 which is provided by Docker images, eliminating the need for installation of these tools on the device. The docker-compose.yml file orchestrates the deployment of both the application and the database containers.